home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / win_u_z / xlock_dv.zip / SOURCES.ZIP / XCRHSBCM.C < prev    next >
C/C++ Source or Header  |  1992-08-07  |  2KB  |  71 lines

  1. #ifndef lint
  2. static char sccsid[] = "@(#)XCrHsbCmap.c 22.2 89/09/20";
  3. #endif
  4. /*-
  5.  * XCrHsbCmap.c - X11 library routine to create an HSB ramp colormaps.
  6.  *
  7.  * Copyright (c) 1989 by Sun Microsystems, Inc.
  8.  *
  9.  * Author: Patrick J. Naughton
  10.  * naughton@sun.com
  11.  *
  12.  * Permission to use, copy, modify, and distribute this software and its
  13.  * documentation for any purpose and without fee is hereby granted,
  14.  * provided that the above copyright notice appear in all copies and that
  15.  * both that copyright notice and this permission notice appear in
  16.  * supporting documentation.
  17.  *
  18.  * This file is provided AS IS with no warranties of any kind.  The author
  19.  * shall have no liability with respect to the infringement of copyrights,
  20.  * trade secrets or any patents by this file or any part thereof.  In no
  21.  * event will the author be liable for any lost revenue or profits or
  22.  * other special, indirect and consequential damages.
  23.  *
  24.  */
  25.  
  26. #include <X11/X.h>
  27. #include <X11/Xos.h>
  28. #include <X11/Xlib.h>
  29.  
  30. extern void HSBmap();
  31.  
  32. Status
  33. XCreateHSBColormap(dsp, screen, cmap, count, h1, s1, b1, h2, s2, b2, bw)
  34.     Display    *dsp;
  35.     int         screen;
  36.     Colormap   *cmap;        /* colormap return value */
  37.     int         count;        /* number of entrys to use */
  38.     double      h1,        /* starting hue */
  39.                 s1,        /* starting saturation */
  40.                 b1,        /* starting brightness */
  41.                 h2,        /* ending hue */
  42.                 s2,        /* ending saturation */
  43.                 b2;        /* ending brightness */
  44.     int         bw;        /* Boolean: True = save black and white */
  45. {
  46.     u_char      red[256];
  47.     u_char      green[256];
  48.     u_char      blue[256];
  49.     unsigned long pixel;
  50.     Status      status;
  51.     Visual     *visual;
  52.     XColor      xcolors[256];
  53.  
  54.     if (count > 256)
  55.     return BadValue;
  56.  
  57.     HSBramp(h1, s1, b1, h2, s2, b2, 0, count - 1, red, green, blue);
  58.  
  59.     if (bw) {
  60.     pixel = WhitePixel(dsp, screen);
  61.     red[pixel] = green[pixel] = blue[pixel] = 0xff;
  62.  
  63.     pixel = BlackPixel(dsp, screen);
  64.     red[pixel] = green[pixel] = blue[pixel] = 0;
  65.     }
  66.     status = XCreateDynamicColormap(dsp, screen, cmap, &visual, xcolors,
  67.                     count, red, green, blue);
  68.  
  69.     return status;
  70. }
  71.